﻿<!DOCTYPE html>

<!--操作程序列表-->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>
<body>
    
<div id="app" v-cloak>   
        <el-row>
            <el-col :span="4">
                <el-tree :data="TreeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
            </el-col>
            <el-col :span="20">
                <el-form ref="form" :inline="true" label-position="right" label-width="100px" :model="formInline" class="demo-form-inline" style="margin-bottom: 15px;">
                    <el-row>
                        <el-col  class="head-tool">
                                <el-button type="primary" @click="onSubmit">{{col.btnSelect}}</el-button>
                                <el-button type="primary" @click="onSubmitForm">{{col.btnConfirm}}</el-button>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.JobSteps" :placeholder="OperatingProcedures.JobSteps" size="mini">
                                        <template slot="prepend">
                                            {{OperatingProcedures.JobSteps+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.JobTask" :placeholder="OperatingProcedures.JobTask"  size="mini">
                                        <template slot="prepend">
                                            {{OperatingProcedures.JobTask+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input  size="mini">
                                        <template slot="prepend">
                                            {{OperatingProcedures.RiskLevel+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.RiskLevel" slot="suffix" :placeholder="OperatingProcedures.RiskLevel">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in RiskLevel" :label="item.value" :value="item.key"></el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.Risk" :placeholder="OperatingProcedures.Risk"  size="mini">
                                        <template slot="prepend">
                                            {{OperatingProcedures.Risk+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.HazardousFactors" :placeholder="OperatingProcedures.HazardousFactors"  size="mini">
                                        <template slot="prepend">
                                            {{OperatingProcedures.HazardousFactors+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.ControlRequirement" :placeholder="OperatingProcedures.ControlRequirement"  size="mini">
                                        <template slot="prepend">
                                            {{OperatingProcedures.ControlRequirement+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                    </el-row>
                </el-form>

                <el-table ref="table" :data="ListItem.tableData"
                          :height="ListItem.tableHeight"
                          border @selection-change="handleSelectionChange" row-style="height:10px"
                          style="width: 100%":row-key="mygetRowKeys">
                    <el-table-column type="selection" align="center" width="55">
                    </el-table-column>

                    <el-table-column prop="JobSteps"
                                     :label="OperatingProcedures.JobSteps" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="JobTask"
                                     :label="OperatingProcedures.JobTask" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="Risk"
                                     :label="OperatingProcedures.Risk"
                                     show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="HazardousFactors"
                                     :label="OperatingProcedures.HazardousFactors" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="ControlRequirement"
                                     :label="OperatingProcedures.ControlRequirement" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="RiskLevel"
                                     :label="OperatingProcedures.RiskLevel" show-overflow-tooltip="true" width="100">
                    </el-table-column>
     
                </el-table>
                <el-row type="flex" justify="end">


                    <el-pagination ref="page" @size-change="handleSizeChange"
                                   @current-change="handleCurrentChange"
                                   :current-page="ListItem.currentPage"
                                   :page-sizes="ListItem.pagesizes"
                                   :page-size="ListItem.pagesize"
                                   :layout="ListItem.layout"
                                   :total="ListItem.total">
                    </el-pagination>

                </el-row>
            </el-col>
        </el-row>

    </div>
    <script type="text/javascript">
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    TreeData: [],
                    mydata: RiskControlInformation,

                    defaultProps: {
                        children: 'children',
                        label: 'label'
                    },
                    RiskLevel: [],
                    ListItem: ListItem,
                    formInline: {
                        model: { JobSteps: '', RiskLevel: '', JobTask: '', Risk: '', HazardousFactors: '', ControlRequirement:''},
                        offset: 0,
                        limit: 10
                    }
                }
            }, created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            mounted: function () {
                this.RiskLevel = getDicData('03');
                //初始化数据
                this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
                this.toggleSelection();
                this.TreeData = fn(this.mydata, "0");
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                mygetRowKeys: function (row) {
                    return row.Risk;
                },
                toggleSelection: function () {
                    var mythis = this;
                    mythis.$nextTick(function () {
                        var rows = parent.app.Form.OperatingProcedureRish;
                        var array = [];
                        for (var i = 0; i < rows.length; i++) {
                            var obj = {};
                            obj.Risk = rows[i];
                            array.push(obj);
                        }
                        if (array) {
                            array.forEach(function (arr) {
                                mythis.$refs.table.toggleRowSelection(arr, true);
                            });
                        } else {
                            mythis.$refs.table.clearSelection();
                        }

                    })
                },
                handleNodeClick: function (data) {
                    console.log(data);
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/OperatingProcedures/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "OperatingProceduresInput.html", id); },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/OperatingProcedures/GetList') },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },

                onSubmitForm: function () {
                    parent.app.Form.OperatingProcedureRish.length;
                    for (var i = 0; i < this.ListItem.tableMultipleSelection.length; i++) {
                        parent.app.Form.OperatingProcedureRish.push(this.ListItem.tableMultipleSelection[i]);
                    }
                    parent.app.ListItem.dialogVisible = false;
                }
            }
        });

    </script>
</body>

</html>
